package com.example.firstfive;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

public class RateTransfActivity extends AppCompatActivity {
    TextView t1;
    EditText e2;
    float rate;
    private static final String TAG = "out";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_rate_transf);

        Intent intent = getIntent();
        String cur = intent.getStringExtra("cur_key");
        rate = intent.getFloatExtra("rate_key",0.0f);

        Log.i(TAG,"onCreate: currency="+cur);
        Log.i(TAG,"onCreate: rate="+rate);

        t1 = (TextView) findViewById(R.id.output);
        t1.setText(cur);
    }//汇率计算
    public void transf(View btn) {
        Log.i(TAG, "save:");
        t1 = (TextView) findViewById(R.id.output);
        //获取新的值
        e2 = (EditText)findViewById(R.id.input);//连接编辑框的id
        float rmb = Float.parseFloat(e2.getText().toString());//获取编辑栏的内容
        Log.i(TAG, "rmb= "+e2);
        float m = (100*rmb)/rate;
        t1.setText(m+"");
}}